$(document).ready(function() {
    $('.btn_add_image img').click(function(){
        var len_other_image = $('.other_image > div').length;
        var html = '<div class="btn-group btn-group-xs btn-group-solid"><img id="other_image_'+len_other_image+'" class="show_image_browse" src="public/upload/images/no-image.jpg" /><input class="order_other_image" type="text" value="" name="order_image[]" title="Sort order"/><input class="other_image_'+len_other_image+'" type="hidden" name="other_image[]" value="public/upload/images/no-image.jpg" /><div class="clear"></div><button class="btn blue fileBrowse" data-target="other_image_'+len_other_image+'" type="button">Browse File</button><button class="btn red fileDelete" data-target="other_image_'+len_other_image+'" type="button">Delete File</button></div>';
        $('.other_image').prepend(html);
    });
});

function open_modal_basic(title, content, link)
{
    var obj_modal = $("#modal_basic");
    obj_modal.find('.modal-title').html(title);
    obj_modal.find('.modal-body').html(content);
    if(link != 'undefined')
    {
        obj_modal.find('button.btn-modal-close').attr('onclick','window.location=\''+link+'\'');
    }
    obj_modal.modal('show');
}

function open_modal_confirm(title, content, array_attr)
{
    console.log(array_attr);
    var text_attr = "";
    
    console.log(text_attr);
    
    var obj_modal = $("#modal_confirm");
    obj_modal.find('.modal-title').html(title);
    obj_modal.find('.modal-body').html(content);
    if(array_attr != 'undefined')
    {
        var key;
        var value;
        for (key in array_attr) {
            value = array_attr[key];
            obj_modal.find('button.btn-modal-accept').attr(key, value);
        }
    }
    obj_modal.modal('show');
}